﻿using System;
namespace Producers.Liiklusregister.Xtee.Riik.Ee.Producer.Liiklusregister {
    
    
    [global::Xtee.Core.Attributes.XmlTypeAttribute(Name="paring22_paring", Namespace="http://producers.liiklusregister.xtee.riik.ee/producer/liiklusregister", Target=typeof(Paring22Paring))]
    public class Paring22ParingSerializer : global::Xtee.Core.Types.AbstractXteeSerializable {
        
        protected IParing22Paring clazz;
        
        public Paring22ParingSerializer(IParing22Paring clazz) {
            this.clazz = clazz;
        }
        
        public override void WriteXml(global::Xtee.Core.IXteeXmlWriter Writer) {
            base.WriteXml(Writer);
            Writer.WriteStartElement("oma_kood");
            if (clazz.OmaKood!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.OmaKood))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : OmaKood");
            }
            Writer.WriteEndElement();
        }
        
        public override void ReadXml(global::Xtee.Core.IXteeXmlReader Reader) {
            base.ReadXml(Reader);
        START:
            if ((Reader.LocalName == "oma_kood")) {
                goto oma_kood;
            }
            else {
                return;
            }
        oma_kood:
            if (Reader.IsElementNil()) {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>paring22_paring>oma_kood");
            }
            clazz.OmaKood = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("oma_kood")).Value;
            goto START;
        }
    }
}
